﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZuoAlgorithms.Class015;

// 最小栈
// 测试链接 : https://leetcode.cn/problems/min-stack/
public class GetMinStack
{
    class MinStack1
    {
        public Stack<int> data;
        public Stack<int> min;
        public MinStack1()
        {
            data = new Stack<int>();
            min = new Stack<int>();
        }

        public void Push(int val)
        {
            data.Push(val);
            if(min .Count ==0 || val <= min .Peek ())
            {
                min.Push(val);
            }
            else
            {
                min.Push(min.Peek());
            }
        }

        public void Pop()
        {
            data.Pop();
            min.Pop();
        }

        public int Top()
        {
            return data.Peek();
        }

        public int GetMin()
        {
            return min.Peek();
        }

    }

    class MinStack2
    {


    }

}
